package com.graduation.apiservice.controller;

import com.graduation.common.domain.dto.PageDTO;
import com.graduation.pojo.po.Case;
import com.graduation.pojo.query.CaseQuery;
import com.graduation.pojo.vo.CaseVO;
import com.graduation.service.CaseService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/case")
@RequiredArgsConstructor
public class CaseController {

    private final CaseService caseService;

    /**
     * 分页查询案件（前台接口）
     * 通过documentId查询相关案件
     */
    @GetMapping("/page")
    public PageDTO<CaseVO> pageCases(CaseQuery query) {
        return caseService.pageCases(query);
    }

    /**
     * 查看案件详情
     */
    @GetMapping("/{id}")
    public Case getCaseById(@PathVariable("id") Long id) {
        return caseService.getCaseById(id);
    }

    /**
     * 获取热门案件列表（基于收藏数量）
     */
    @GetMapping("/hot")
    public List<CaseVO> listHotCase() {
        return caseService.listHotCase();
    }

}